package cumt.oj;

import java.util.Scanner;

/**
 * @Author Fizz Pu
 * @Date 2020/12/7 下午1:00
 * @Version 1.0
 * 失之毫厘，缪之千里！
 */
public class HomeC {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int total = scanner.nextInt();

        for(int i = 0; i < total; ++i){
            int N = scanner.nextInt();
            int K = scanner.nextInt();
            int[] score = new int[N];
            for(int j = 0; j < N; ++j){
                score[j] = scanner.nextInt();
            }

            int target = score[K-1];
            int count = 0;
            for(int each : score){
                if(each > target){count++;}
            }

            System.out.println(count);
        }

    }
}
